﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DemoGo
{
    //定义枚举
    enum EggType
    {
        blueEgg,
        goldEgg,
        normalEgg,
        spoiledEgg,
        junk
    }

    /// <summary>
    /// 鸡蛋
    /// </summary>
    class Egg
    {
        public Rectangle Rectangle { get; set; }
        //鸡蛋竖直下落速度
        private int SpeedY;

        public EggType EggType { get; set; }

        /// <summary>
        /// 产生一个指定类型的鸡蛋
        /// </summary>
        /// <param name="rec"></param>
        /// <param name="eggType"></param>
        public Egg(Rectangle rec,EggType eggType)
        {
            Rectangle = rec;
            SpeedY += 20;
            EggType = eggType;
        }

        /// <summary>
        /// 绘图4种鸡蛋和鸡粪便
        /// </summary>
        /// <param name="g"></param>
        public void Draw(Graphics g)
        {
            //画不同类型的鸡蛋
            switch (EggType)
            {
                case EggType.blueEgg:
                    g.DrawImage(Properties.Resources.blueEgg, Rectangle);
                    break;
                case EggType.goldEgg:
                    g.DrawImage(Properties.Resources.goldEgg, Rectangle);
                    break;
                case EggType.normalEgg:
                    g.DrawImage(Properties.Resources.normalEgg, Rectangle);
                    break;
                case EggType.spoiledEgg:
                    g.DrawImage(Properties.Resources.spoiledEgg, Rectangle);
                    break;
                case EggType.junk:
                    g.DrawImage(Properties.Resources.junk, Rectangle);
                    break;
                default:
                    break;
            }
        }

        /// <summary>
        /// 鸡蛋下落
        /// </summary>
        public void Move(Size size)
        {
            //鸡蛋竖直下落
            this.Rectangle = new Rectangle(this.Rectangle.X, 
                                           this.Rectangle.Y + SpeedY, 
                                           Rectangle.Width, 
                                           Rectangle.Height);
        }
    }
}
